#include "Buttond.h"
#include "ui_Buttond.h"
#include <qmessagebox.h>
Buttond::Buttond(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Buttond)
{
    ui->setupUi(this);
}

Buttond::~Buttond()
{
    delete ui;
}
void Buttond::init()
{
    ui->spinBox_danger->setValue(0);
    ui->spinBox_enddir->setValue(0);
    ui->spinBox_far->setValue(0);
    ui->spinBox_near->setValue(0);
    ui->spinBox_stardir->setValue(0);
    ui->lineEdit_info->setText("");
}
void Buttond::on_pushButton_o_clicked()
{
    if(ui->spinBox_stardir->value()>ui->spinBox_enddir->value()){
        QMessageBox::information(this,"警告","结束方位必须大于起始方位!");
        return;
    }
    if(ui->spinBox_near->value()>ui->spinBox_far->value()){
        QMessageBox::information(this,"警告","远界必须大于近界!");
        return;
    }
    if(ui->spinBox_danger->value()>0
            && ui->spinBox_stardir->value()>0
            && ui->spinBox_enddir->value()>0
            && ui->spinBox_far->value()>0)
    {
        emit senddata_d(ui->spinBox_danger->value(),
                        ui->lineEdit_info->text(),
                        ui->spinBox_stardir->value(),
                        ui->spinBox_enddir->value(),
                        ui->spinBox_near->value(),
                        ui->spinBox_far->value());
        this->accept();
        init();
    }
    else
    {
        QMessageBox::information(this,"警告","请指定相关参数!或点击【取消】退出界面！");
        return;
    }
}

void Buttond::on_pushButton_c_clicked()
{
    this->accept();
    init();
}
